package com.symc.his.api.impl.mapper;

import com.symc.his.api.impl.entity.PatientInfoDO;
import java.util.List;
import org.apache.ibatis.annotations.Select;

/**
 * @Description: 
 * @CreateTime: 2023/3/5 19:19
 * @Version: 
 * @Since: 1.8
 * @Author: 辛凤文 forward.seen@foxmail.com 
 */
public interface PatientInfoMapper extends BaseMapper<PatientInfoDO> {

    /**
     * 根据病人档案号、病人姓名、病人身份证号查询符合条件的病人列表（模糊查询）
     * @param patientId
     * @param name
     * @param identifyNo
     * @return
     */
    @Select("<script>\n" +
        "SELECT\n" +
        "\tpatient_info_id,\n" +
        "\tpatient_id,\n" +
        "\tNAME,\n" +
        "\tsex_code,\n" +
        "\tage,\n" +
        "\tbirth_date,\n" +
        "\tpatient_tel,\n" +
        "\tidentify_type_code,\n" +
        "\tidentify_no,\n" +
        "\tvalid_state,\n" +
        "\toper_code,\n" +
        "\tremark,\n" +
        "\tcompound_id,\n" +
        "\tcreate_time,\n" +
        "\tupdate_time \n" +
        "FROM\n" +
        "\tfoundation.com_patient_info \n" +
        " <where>\n" +
        "\tvalid_state = 1 \n" +
        "\t<if test=\"patientId != null and patientId != '' \"> AND patient_id LIKE CONCAT( '%', #{ patientId }, '%' ) </if>\n" +
        "\t<if test=\"name != null and name != '' \">AND name LIKE CONCAT( '%', #{ name }, '%' ) </if>\n" +
        "\t<if test=\"identifyNo != null and identifyNo != '' \">AND identify_no LIKE CONCAT('%' #{identifyNo},'%')</if>\n" +
        "</where>\n" +
        "</script>")
    List<PatientInfoDO> queryPatientInfoListByPatientIdAndNameAndIdentifyNo(String patientId,String name,String identifyNo);

    /**
     * 根据病人档案号、病人姓名、病人身份证号分页查询符合条件的病人列表（模糊查询）
     * @param patientId
     * @param name
     * @param identifyNo
     * @param currentPageNum
     * @param pageSize
     * @return
     */
    @Select("<script>\n" +
        "SELECT\n" +
        "\tpatient_info_id,\n" +
        "\tpatient_id,\n" +
        "\tNAME,\n" +
        "\tsex_code,\n" +
        "\tage,\n" +
        "\tbirth_date,\n" +
        "\tpatient_tel,\n" +
        "\tidentify_type_code,\n" +
        "\tidentify_no,\n" +
        "\tvalid_state,\n" +
        "\toper_code,\n" +
        "\tremark,\n" +
        "\tcompound_id,\n" +
        "\tcreate_time,\n" +
        "\tupdate_time \n" +
        "FROM\n" +
        "\tfoundation.com_patient_info \n" +
        " <where>\n" +
        "\tvalid_state = 1 \n" +
        "\t<if test=\"patientId != null and patientId != '' \"> AND patient_id LIKE CONCAT( '%', #{ patientId }, '%' ) </if>\n" +
        "\t<if test=\"name != null and name != '' \">AND name LIKE CONCAT( '%', #{ name }, '%' ) </if>\n" +
        "\t<if test=\"identifyNo != null and identifyNo != '' \">AND identify_no LIKE CONCAT('%' #{identifyNo},'%')</if>\n" +
        "</where>\n" +
        " LIMIT #{currentPageNum} , #{pageSize}" +
        "</script>")
    List<PatientInfoDO> queryPatientInfoPageByPatientIdAndNameAndIdentifyNo(String patientId,String name,String identifyNo,Long currentPageNum, Long pageSize);


}